Equation Solving
The Wolfram Language encompasses the world's most extensive array of numerical and symbolic equation-solving tools, featuring numerous pioneering algorithms. These are all readily accessible via a limited set of highly efficient functions. Thanks to the symbolic framework of the Wolfram Language, both equations and their solutions can be easily represented symbolically, and seamlessly incorporated into computations and visualizations.
Solve
Address a quadratic equation.
Download original notebooksol = Solve[(*SpB[*)Power[x(*|*),(*|*)2](*]SpB*) + a x + 1 == 0, x]
{{x->((*FB[*)((1)(*,*)/(*,*)(2))(*]FB*)) (-a-(*SqB[*)Sqrt[-4+(*SpB[*)Power[a(*|*),(*|*)2](*]SpB*)](*]SqB*))},{x->((*FB[*)((1)(*,*)/(*,*)(2))(*]FB*)) (-a+(*SqB[*)Sqrt[-4+(*SpB[*)Power[a(*|*),(*|*)2](*]SpB*)](*]SqB*))}}
Solve simultaneous equations in and
Solve[a x + y == 7 && b x - y == 1, {x, y}]
{{x->(*FB[*)((8)(*,*)/(*,*)(a+b))(*]FB*),y->-(*FB[*)((a-7 b)(*,*)/(*,*)(a+b))(*]FB*)}}
Solve equations in a geometric region
Solve[ Element[{x, y}, InfiniteLine[{{0, 0}, {2, 1}}]] && Element[{x, y}, Circle[]] , {x, y}]
{{x->-(*FB[*)((2)(*,*)/(*,*)((*SqB[*)Sqrt[5](*]SqB*)))(*]FB*),y->-(*FB[*)((1)(*,*)/(*,*)((*SqB[*)Sqrt[5](*]SqB*)))(*]FB*)},{x->(*FB[*)((2)(*,*)/(*,*)((*SqB[*)Sqrt[5](*]SqB*)))(*]FB*),y->(*FB[*)((1)(*,*)/(*,*)((*SqB[*)Sqrt[5](*]SqB*)))(*]FB*)}}
Graphics[{{Blue, Line[Normalize /@ {-{2, 1}, {2, 1}}], Circle[{0,0}, 1]}, {PointSize[Large], Red, Point[{x, y}] /. %}}, AspectRatio->1, ImageSize->Small]
(*VB[*)(FrontEndRef["77e3851b-8470-4241-a0b0-9e2b32a33412"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKm5unGluYGibpWpiYG+iaGJkY6iYaJBnoWqYaJRkbJRobmxgaAQBx8BSf"*)(*]VB*)
NSolve
Approximate solutions to a polynomial equation:
NSolve[(*SpB[*)Power[x(*|*),(*|*)5](*]SpB*) - 2 x + 3 == 0, x]
{{x->-1.4236058485523317`},{x->-0.24672925691056408`-1.3208163474502472` I},{x->-0.24672925691056408`+1.3208163474502472` I},{x->0.9585321811867298` -0.49842777903184593` I},{x->0.9585321811867298` +0.49842777903184593` I}}
Solve the equation
eq[z_] := Sin[z + Sin[z + Sin[z]]] == Cos[z + Cos[z + Cos[z]]] roots = NSolve[eq[z] && -3 < Re[z] < 3 && -3 < Im[z] < 3, z, MaxRoots -> Infinity];
ListPlot[{Re[z], Im[z]} /. roots, PlotLabel -> ToString[Sin[z + Sin[z + Sin[z]]] == Cos[z + Cos[z + Cos[z]]]]]
(*VB[*)(FrontEndRef["f7a08193-ad1d-4419-b796-e757c01d1fb1"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKp5knGlgYWhrrJqYYpuiamBha6iaZW5rpppqbmicbGKYYpiUZAgCAGhV0"*)(*]VB*)
FindRoot
Searches for a numerical root
Find the solution near 0
FindRoot[Cos[x] == x, {x, 0}]
{x->0.7390851332151607`}
Solve a nonlinear system of equations:
FindRoot[{Exp[x - 2] == y, y^2 == x}, {{x, 1}, {y, 1}}]
{x->0.019026016103714054`,y->0.13793482556524314`}
Compute inverse function
inv[f_, s_] := Function[{t}, s /. FindRoot[f - t, {s, 1}]]
Approximate exponent
einv = inv[Exp[x], x] Plot[{einv[x], Log[x] + 0.5}, {x, 0, 1}, PlotRange -> All]
Function[{t$},x/. FindRoot[(*SpB[*)Power[E(*|*),(*|*)x](*]SpB*)-t$,{x,1}]]
(*VB[*)(FrontEndRef["d672b5b7-6311-4f00-82a3-d67392ad06f5"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKp5iZGyWZJpnrmhkbGuqapBkY6FoYJRrrAsWNLY0SUwzM0kwBeK4VDg=="*)(*]VB*)
Find minimum
Find a local minimum, starting the search at :
FindMinimum[x Cos[x], {x, 2}]
{-3.2883713955908966`,{x->3.425618459492147`}}
Plot[x Cos[x], {x, 0, 20}, Prolog->{Red, Line[{{0,0}, {20,0}}]}]
(*VB[*)(FrontEndRef["241d39f0-7923-42c1-b6dd-586077aebc69"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKG5kYphhbphnomlsaGeuaGCUb6iaZpaTomlqYGZibJ6YmJZtZAgB2xxVK"*)(*]VB*)
Find a minimum of a function over a geometric region:
FindMinimum[{x + y, Element[{x, y}, Disk[]]}, {x, y}]
{-1.4142152367632073`,{x->-0.7071076183816036`,y->-0.7071076183816036`}}
Show[ContourPlot[x + y, Element[{x, y}, Disk[]]], Graphics[{Red, PointSize[Large], Point[{x, y} /. Last[%]]}], ImageSize->300]
(*VB[*)(FrontEndRef["d9bb0245-4d86-4aa6-a23b-378bf02eeb6b"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKp1gmJRkYmZjqmqRYmOmaJCaa6SYaGSfpGptbJKUZGKWmJpklAQCF/RX5"*)(*]VB*)
Minimize
Minimize a univariate function:
Minimize[2 (*SpB[*)Power[x(*|*),(*|*)2](*]SpB*) - 3 x + 5, x]
{(*FB[*)((31)(*,*)/(*,*)(8))(*]FB*),{x->(*FB[*)((3)(*,*)/(*,*)(4))(*]FB*)}}
A minimization problem containing parameters:
Minimize[a (*SpB[*)Power[x(*|*),(*|*)2](*]SpB*) + b x + c, x]
{(*TB[*)Piecewise[{{(*|*)c(*|*),(*|*)(b==0&&a==0)||(b==0&&a>0)(*|*)},{(*|*)(*FB[*)((-((*SpB[*)Power[b(*|*),(*|*)2](*]SpB*))+4 a c)(*,*)/(*,*)(4 a))(*]FB*)(*|*),(*|*)(b>0&&a>0)||(b<0&&a>0)(*|*)},{(*|*)-Infinity(*|*),(*|*)True(*|*)}}](*|*)(*1:eJxTTMoPSmNiYGAo5gUSYZmp5S6pyflFiSX5RcGcQJGAzNTk1PLM4tRMZiAPAA9oC9E=*)(*]TB*),{x->(*TB[*)Piecewise[{{(*|*)-(*FB[*)((b)(*,*)/(*,*)(2 a))(*]FB*)(*|*),(*|*)(b>0&&a>0)||(b<0&&a>0)(*|*)},{(*|*)0(*|*),(*|*)(b==0&&a==0)||(b==0&&a>0)(*|*)},{(*|*)Indeterminate(*|*),(*|*)True(*|*)}}](*|*)(*1:eJxTTMoPSmNiYGAo5gUSYZmp5S6pyflFiSX5RcGcQJGAzNTk1PLM4tRMZiAPAA9oC9E=*)(*]TB*)}}
NMinimize
Find the global minimum of an unconstrained problem:
NMinimize[(*SpB[*)Power[x(*|*),(*|*)4](*]SpB*) - 3 (*SpB[*)Power[x(*|*),(*|*)2](*]SpB*) - x, x]
{-3.5139050389347886`,{x->1.300839565947765`}}
Find the global minimum of problems with constraints:
NMinimize[{(*SpB[*)Power[x(*|*),(*|*)2](*]SpB*) - (*SpB[*)Power[(y - 1)(*|*),(*|*)2](*]SpB*), (*SpB[*)Power[x(*|*),(*|*)2](*]SpB*) + (*SpB[*)Power[y(*|*),(*|*)2](*]SpB*) <= 4}, {x, y}]
{-9.000000014992256`,{x->2.8850141663858584`*^-10,y->-2.0000000024987092`}}
Linear Solve
Solve the matrix-vector equation
{{r, s}, {t, u}}//MatrixForm
((*GB[*){{r(*|*),(*|*)s}(*||*),(*||*){t(*|*),(*|*)u}}(*]GB*))
Substitute it to LinearSolve
LinearSolve[((*GB[*){{r(*|*),(*|*)s}(*||*),(*||*){t(*|*),(*|*)u}}(*]GB*)), {y, z}]
{(*FB[*)((u y-s z)(*,*)/(*,*)(-s t+r u))(*]FB*),(*FB[*)((t y-r z)(*,*)/(*,*)(s t-r u))(*]FB*)}
Solve a rectangular matrix equation
m = ((*GB[*){{1(*|*),(*|*)5}(*||*),(*||*){2(*|*),(*|*)6}(*||*),(*||*){3(*|*),(*|*)7}(*||*),(*||*){4(*|*),(*|*)8}}(*]GB*)); b = ((*GB[*){{9}(*||*),(*||*){10}(*||*),(*||*){11}(*||*),(*||*){12}}(*]GB*)); LinearSolve[m,b]
{{-1},{2}}
Verify
m.% == b
True
RSolve
Solve a difference equation
RSolve[a[n + 1] - 2 a[n] == 1, a[n], n]
{{a[n]->-1+(*SpB[*)Power[2(*|*),(*|*)n](*]SpB*)+((*SpB[*)Power[2(*|*),(*|*)-1+n](*]SpB*)) (*SbB[*)Subscript[C(*|*),(*|*)1](*]SbB*)}}
Include a boundary condition:
RSolve[{a[n + 1] - 2 a[n] == 1, a[0] == 1}, a[n], n]
{{a[n]->-1+(*SpB[*)Power[2(*|*),(*|*)1+n](*]SpB*)}}
And many more!
Visit Wolfram Language documentation center